00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _goss_utils_h_
00019 #define _goss_utils_h_
00020
00021
00022
00023 #ifdef GOSS_DEBUG
00024 #define USE_GOSS
00025 #endif
00026
00027 #ifdef USE_GOSS
00028 #include <boost/smart_ptr/shared_ptr.hpp>
00029 #include "gridpack/parallel/distributed.hpp"
00030 #include "gridpack/network/base_network.hpp"
00031 #include "gridpack/component/base_component.hpp"
00032 #include "gridpack/utilities/exception.hpp"
00033 #ifndef GOSS_DEBUG
00034 #include <activemq/library/ActiveMQCPP.h>
00035 #include <decaf/lang/Thread.h>
00036 #include <decaf/lang/Runnable.h>
00037 #include <decaf/util/concurrent/CountDownLatch.h>
00038 #include <decaf/lang/Integer.h>
00039 #include <decaf/lang/Long.h>
00040 #include <decaf/lang/System.h>
00041 #include <activemq/core/ActiveMQConnectionFactory.h>
00042 #include <activemq/util/Config.h>
00043 #include <cms/Connection.h>
00044 #include <cms/Session.h>
00045 #include <cms/TextMessage.h>
00046 #include <cms/BytesMessage.h>
00047 #include <cms/MapMessage.h>
00048 #include <cms/ExceptionListener.h>
00049 #include <cms/MessageListener.h>
00050 using namespace activemq::core;
00051 using namespace decaf::util::concurrent;
00052 using namespace decaf::util;
00053 using namespace decaf::lang;
00054 using namespace cms;
00055 #endif
00056
00057 namespace gridpack {
00058 namespace goss {
00059
00060
00061
00062
00063
00064 class GOSSUtils {
00065
00066 public:
00067
00068
00069
00070
00071
00072 static GOSSUtils *instance();
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 void initGOSS(std::vector<std::string> &topics, const char *URI,
00083 const char* username, const char *passwd);
00084
00085
00086
00087
00088
00089
00090
00091 void openGOSSChannel(gridpack::parallel::Communicator &comm,
00092 const std::string topic);
00093
00094
00095
00096
00097 void closeGOSSChannel(gridpack::parallel::Communicator &comm);
00098
00099
00100
00101
00102
00103 void sendGOSSMessage(std::string &text);
00104
00105
00106
00107
00108 void sendChannelMessage(const char *topic, const char *URI,
00109 const char *username, const char *passwd, const char *msg);
00110
00111
00112
00113
00114 void terminateGOSS();
00115
00116 protected:
00117
00118
00119
00120
00121 GOSSUtils();
00122
00123
00124
00125
00126 ~GOSSUtils();
00127
00128 private:
00129
00130
00131
00132
00133 std::string p_URI;
00134 std::string p_username;
00135 std::string p_passwd;
00136 std::string p_current_topic;
00137
00138 #ifndef GOSS_DEBUG
00139 Connection *p_connection;
00140 Session *p_session;
00141 Destination *p_destination;
00142 MessageProducer *p_producer;
00143 #endif
00144 bool p_open;
00145 int p_grp;
00146
00147
00148
00149 static GOSSUtils *p_instance;
00150 };
00151 }
00152 }
00153 #endif
00154 #endif